define(function(require,exports,module){
	

	//字数限制
/*	require.async('textLimit',function(){
		$('textarea').limitTextarea({
			maxNumber:100,
			position:'bottom',
			overClass:'overText',
			onOk:function(){},
			onOver:function(){}
		});
	});*/

	//检测类
	var Auth = require('qd-auth-1.0');
	
	//申请额度验证
	require.async("/plugins/jquery-validation-1.13.0/jquery.validate",function(){
		$("#addAmountApply").validate({
			rules:{
				amount:{
					required:true,
					min:1,
					max:10000
				},
				content:{
					required:true
				}
			},
			messages:{
				amount:{
					required:"请填写申请金额",
					min:"申请金额最小为1元",
					max:"申请金额不能超过10000元"
				},
				content:{
					required:"请写上详细信息"
				}
			},
			errorPlacement:function(error, element){
			  	element.parents(".ipt").find("em").html(error);	
			},
			success:function(element){
				element.parents(".ipt").find("em").html("");
			},
		    success:function(label){
		    },
		    submitHandler:function(form,event,validator){
				 require.async('jquery.form',function(){
					 $(form).ajaxSubmit({
   					dataType:'json',
   					success:function(data){
						//单点登录检测
						if(Auth.checkLogin(arguments[0]) == false) {return ;}

						require.async('common1',function(msgBox){
	    						if(data.result){
	    							msgBox.messageBox(1,"申请已提交，等待系统审核！","/member/borrow/creditApply.html");
		    					}else{
		    						msgBox.messageBox(2,data.msg);
		    						$("#addAmountApply")[0].reset();
		    					}
	    					})
   					}
   				});				
				 })
			}
		    
		    
		});
	})

});